//
//  YHBLETool.h
//  BLE4.0Example
//
//  Created by zxy on 2017/9/27.
//  Copyright © 2017年 saint. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import <UIKit/UIKit.h>
#import "YHPeripheral.h"

extern NSString *const YH_BLE_CBPeripheral_found;
extern NSString *const YH_BLE_SCANFSTATE;
extern NSString *const YH_BLE_MESSAGE_COMMING;


@interface YHBLECentralManager : NSObject<CBCentralManagerDelegate,CBPeripheralDelegate>

@property (nonatomic, strong) CBCentralManager *centerManager;

@property (nonatomic, strong) NSMutableArray<CBPeripheral *> *peripherals; //!< 当前扫描到的蓝牙设备

@property (nonatomic, strong) NSTimer *scanfTimer;

@property (nonatomic, strong) CBPeripheral *currentConnectedPeripheral; //!< 当前连接的外设

@property (nonatomic, strong) NSMutableData *reciveBuffer;

+(instancetype)shared;



/**
 开始扫描周边蓝牙设备
 */
- (void)startScan;


- (void)startScanWith:(NSTimeInterval )time;

/**
 停止扫描
 */
- (void)stopScan;


//连接外设
/**
 <#Description#>

 @param peripheral 连接外设
 */
- (void)connectTo:(CBPeripheral*)peripheral;


/**
 断开当期连接
 */
- (void)disConnect;

- (void)sendMessage:(NSData *)data;

@end
